{{include '../common/header.html'}}

<body>
    <div class="page-container">
        <form class="form form-horizontal" id="add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>班级名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" name="cls-id">
                            {{each classList}}
                            <option value="{{$value.id}}">{{$value.name}}</option>
                            {{/each}}
                        </select>
                    </span>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>数据文件：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="file" class="input-text" autocomplete="off" name="file">
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button class="btn btn-primary radius" type="button">
                        <i class="Hui-iconfont">&#xe632;</i> 确认导入
                    </button>
                </div>
            </div>
        </form>
    </div>
    {{include '../common/script.html'}}
    <script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script>
        $(function () {
            $('.btn-primary').click(function (e) {
                let fd = new FormData(document.getElementById('add'));
                $.ajax(
                    {
                        url: '/admin-student-import',
                        type: 'POST',
                        data: fd,
                        contentType: false,
                        processData: false,
                        success: function (data) {
                            if (data.code) {
                                layer.alert(data.msg, { icon: 5 })
                            } else {
                                layer.alert(data.msg, { icon: 6 }, function () {
                                    location.reload();
                                })
                            }
                        }
                    }
                )



                // $(this).serialize()

                // $.post('', $(this).serialize(), function(data){
                //     if(data.code){
                //         layer.alert(data.msg, {icon: 5})
                //     }else{
                //         layer.alert(data.msg, {icon: 6}, function(){
                //             location.reload();
                //         })
                //     }
                // });


            });
        });
    </script>
</body>

</html>